<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="../src/css/layui.css">
    <style>
      body{padding: 16px;}
    </style>
  </head>
<body>
	<div class="content">
		<div class="login_info">
			<div class="login_title">
				总控登录
			</div>
		  <form class="layui-form layui-form-pane1"  metlay-filter="first">
			
			<div class="layui-form-item">
			  <label class="layui-form-label">账号</label>
			  <div class="layui-input-block">
				<input type="text" name="account" placeholder="请输入账号" lay-verify="required|account" autocomplete="off" class="layui-input demo-phone">
			  </div>
			</div>
			
			<div class="layui-form-item">
			  <label class="layui-form-label">密码</label>
			  <div class="layui-input-inline">
				<input type="password" name="password" lay-verify="required|pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
			  </div>
			</div>
			<!-- <div class="layui-form-item">
			  <label class="layui-form-label">验证码</label>
			  <div class="layui-input-inline">
				<input type="text" name="vercode" lay-verify="required" autocomplete="off" class="layui-input">
			  </div>
			  <div class="layui-form-mid" style="padding: 0!important;"> 
				<button type="button" class="layui-btn layui-btn-primary" lay-on="get-vercode">获取验证码</button>
			  </div>
			</div> -->
			
			<div class="layui-form-item">
			  <div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="login">登录</button>
			  </div>
			</div>
		  </form>
		</div>
	</div>

  <script src="../src/layui.js" ></script>
  <script>

  layui.use(['form', 'util', 'laydate'], function(){
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var util = layui.util;
    var laydate = layui.laydate;

    //自定义验证规则
    form.verify({
      account: function(value){
        if(value.length < 0){
          return '请输入账号';
        }
      }
      ,pass: function(value){
        if(value.length < 0){
          return '请输入密码';
        }
      }
    });
    
    
    // 提交事件
    form.on('submit(login)', function(data){
		postData = JSON.stringify(data.field);
		$.ajax({
			url : './loginInfo',
			type : 'post',
			dataType : 'json',
			contentType :"application/json",
			data : postData,
			success : function (backData) {
				//登录成功
			  if(backData['status'] == 200){
				  layer.msg(backData.message,{time:1200},function(){
					  top.location.href = '/admin/index/index';
				  });
			  }else{
				  layer.msg(backData.message);
			  }
			}
		})
      return false;
    });
  });

  </script>
</body>
<style>
	body{
		background-image:url(../src/image/adminbg.jpg);
	}

	body .login_info{
		opacity: 1;
		width: 500px;
		margin:300px auto;
		background-color: #eee;
		padding-bottom: 20px;
	}
	.login_info .login_title{
		font-size: 22px;
		text-align: center;
		padding:20px 0 20px 0;
		
	}
	.login_info .layui-form{
		
		
		
	}
	.login_info .layui-form input{
		width:300px;
	}
</style>
</html>
